package zeebe.gateway.EventBased;

import io.vertx.core.json.JsonObject;
import io.zeebe.client.ZeebeClient;

public class EventBasedGatewayStart {
    public static void main(String[] args) {
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("启动工作流");
        String processId = "eventBasedGateway";

        JsonObject input=new JsonObject()
                .put("world","good");

        client.newCreateInstanceCommand()
                .bpmnProcessId(processId)
                .latestVersion()
                .variables(input.encode())
                .send()
                .join();


        //发送消息事件--可有可无
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String correlationKey="good";
        client.newPublishMessageCommand()
                .messageName("hello")
                .correlationKey(correlationKey)
                .send()
                 .join();
        System.out.println("msg消息发送完成");
    }
}
